<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<%
post=saferequest("post",1)

call CheckRights(clng(post),1)


	sch=trim(SafeRequest("sch",0))
	ksrq=trim(SafeRequest("ksrq",0))
	if ksrq<>"" then ksrq=cdate(ksrq)
	jsrq=trim(SafeRequest("jsrq",0))
	if jsrq<>"" then jsrq=cdate(jsrq)
	kssj=trim(SafeRequest("kssj",0))
	if kssj<>"" then kssj=cdate(kssj)
	jssj=trim(SafeRequest("jssj",0))
	if jssj<>"" then jssj=cdate(jssj)
	bzkssj=trim(replace(request.QueryString("bzkssj"),"'","''"))
	if bzkssj<>"" then bzkssj=cdate(bzkssj)
	bzjssj=trim(replace(request.QueryString("bzjssj"),"'","''"))
	if bzjssj<>"" then bzjssj=cdate(bzjssj)
	tyr=SafeRequest("tyr",0)
	cyr=SafeRequest("cyr",0)
	If cyr="" Or cyr="承运人" Then cyr=0
	cd=SafeRequest("cd",0)
	If cd="" Or cd="车队" Then cd=0
	js=trim(SafeRequest("js",0))
	yf=trim(SafeRequest("yf",0))
	yc=trim(SafeRequest("yc",0))
	baozhang=Trim(saferequest("baozhang",0))
	sql="select * from yb LEFT JOIN cl ON yb.cyr = cl.clid where "
	if ksrq<>"" and jsrq<>"" then
		sql=sql&"(rq>=#"&ksrq&"# and rq<=#"&jsrq&"#) and "
	end if
	if kssj<>"" and jssj<>"" then
		sql=sql&"(lrsj>=#"&kssj&"# and lrsj<=#"&jssj&"#) and "
	end If
	if bzkssj<>"" and bzjssj<>"" then
		sql=sql&"(baozhangsj>=#"&bzkssj&"# and baozhangsj<=#"&bzjssj&"#) and "
	end if
	if tyr<>"托运人" Or tyr="" then
		sql=sql&"tyr='"&tyr&"' and "
	end if
	if cyr<>0 then
		sql=sql&"cyr="&cyr&" and "
	end if
	if cd<>0 then
		sql=sql&"cl.sscd="&cd&" and "
	end if
	if js<>"" then
		sql=sql&"js="&js&" and "
	end if
	if yf<>"" then
		sql=sql&"yf="&yf&" and "
	end if
	if baozhang<>"" then
		sql=sql&"baozhang="&baozhang&" and "
	end if
	xx=saferequest("xx",0)
sql=sql&"(tx like '%"&sch&"%' or bz like '%"&sch&"%' or hx like '%"&sch&"%' or tyr like '%"&sch&"%' or cyr like '%"&sch&"%' or dd like '%"&sch&"%' or cmhc like '%"&sch&"%' or tdh like '%"&sch&"%' or xh like '%"&sch&"%' or fh like '%"&sch&"%') and xx like '%"&xx&"%' and post=2 "
	'response.write sql
	'response.end
	sum_sql="select sum(yj) as s_yj,sum(dcf) as s_dcf,sum(jgf) as s_jgf,sum(yfjgf) as s_yfjgf,sum(jsj) as s_jsj,sum(qtf) as s_qtf,sum(chanzhi) as s_chanzhi,sum(sjrlf) as s_sjrlf,sum(thf) as s_thf,sum(dz) as s_dz from ("&sql&")"
	set rs_sum = Server.CreateObject("ADODB.Recordset")
	rs_sum.open sum_sql,conn,1,1
	If Not rs_sum.eof Then
		s_yj=rs_sum("s_yj")
		s_dcf=rs_sum("s_dcf")
		s_jgf=rs_sum("s_jgf")
		s_yfjgf=rs_sum("s_yfjgf")
		s_jsj=rs_sum("s_jsj")
		s_qtf=rs_sum("s_qtf")
		s_chanzhi=rs_sum("s_chanzhi")
		s_sjrlf=rs_sum("s_sjrlf")
		s_thf=rs_sum("s_thf")
		s_dz=rs_sum("s_dz")
		s_glcbf=(s_jsj+s_yfjgf)*0.1
		s_yue=s_jsj+s_yfjgf-s_dz-s_glcbf
	End If
	rs_sum.close
	sql=sql&"order by rq,tyr,tdh,cyr,dd,id"
	'response.write sql
	set rs = Server.CreateObject("ADODB.Recordset")
	rs.open sql,conn,1,1
	If rs.eof Then
		response.write("没有检索到数据!")
		response.end
	End if
If saferequest("page",0)<>""  Then	page=clng(saferequest("page",0)) Else	page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
	if Not IsNumeric(page) then '判断page_num值是否为数字
		page=1
	else
		page = clng(page) '接收page_num并化为数字型赋给page_num变量
	end if
	if page > pagecount then '如果接收的页数大于总页数
		rs.AbsolutePage = pagecount '设置当前显示页等于最后页
	elseif page <= 0 then '如果page小于等于0
		page=1
		rs.AbsolutePage = page '设置当前显示页等于第一页
	else
		rs.AbsolutePage = page '如果大于零,显示当前页等于接收的页数
	end if
	page = rs.AbsolutePage
end if
%>
<table class="contable">
	<thead>
		<tr>
			<th><input id="checkall" type="checkbox" /></th>
			<th>序号</th>
			<th>日期</th>
			<th>托运人</th>
			<th>承运人</th>
			<th>地点</th>
			<th>时间</th>
			<% if yc<>"yue" then %>
			<th>船名/航次</th>
			<% End If %>
			<th>提单号</th>
			<th>箱型</th>
			<th>箱号</th>
			<% if yc<>"yue" then %>
			<th>封号</th>
			<% End If %>
			<% If yc="chanzhi" Then %>
			<th>产值</th>
			<th>实际燃料</th>
			<th>提还</th>
			<% else %>
			<% If yc="yj" Or yc="" Then %>
				<% 'If Session("MM_Post")=0 Then %>
			<th>应收运费</th>
				<% 'End If %>
			<% End If %>
			<% If yc="jsj" Or yc="" or yc="yue" Then %>
			<th>应付运费</th>
			<% End If %>
			<th>堆存费</th>
			<th>提箱</th>
			<th>还箱</th>
			<% If yc="yj" Or yc="" Then %>
			<th>应收进港费</th>
			<% End If %>
			<% If yc="jsj" Or yc="" or yc="yue" Then %>
			<th>应付进港费</th>
			<% End If %>
			<th>其他费</th>
			<% if yc="yue" then %>
			<th>垫资</th>
			<th>管理</th>
			<th>余额</th>
			<th>报账</th>
			<% End If %>
			
			
			<th>备注</th>
			<% If yc="" Then %>
			<th>已收</th>
			<th>已付</th>
			<% End If %>
			<% End If %>
		</tr>
	</thead>
	<tbody>
<%
'while not rs.eof
	For i=1 To pagesize
		If rs.eof Then Exit for
%>
  <tr>
		<td><input type="checkbox" name="checkid" class="checkid" value="<%=rs("id")%>" /></td>
		<td><a href="view.asp?id=<%=rs("id")%>" target="_blank"><%=rs.AbsolutePosition%></a></td>
    <td title="<%=rs("rq")%>"><%=ShortDate(rs("rq"))%></td>
    <td><%=rs("tyr")%></td>
    <td><%=rs("cph")%></td>
    <td><%=rs("dd")%></td>
    <td><%if not isnull(rs("sj")) then response.write(FormatDateTime(rs("sj"),4))%></td>
	<% if yc<>"yue" then %>
    <td><%=rs("cmhc")%></td>
	<% End If %>
    <td><%=rs("tdh")%></td>
    <td><%=rs("xx")%></td>
		<td><%=rs("xh")%></td>
	<% if yc<>"yue" then %>
		<td><%=rs("fh")%></td>
	<% End If %>
	<% If yc="chanzhi" Then %>
		<td><%=rs("chanzhi")%></td>
		<td><%=rs("sjrlf")%></td>
		<td><%=rs("thf")%></td>
	<% else %>
	<% If yc="yj" Or yc="" Then %>
				<% 'If Session("MM_Post")=0 Then %>
		<td><%=rs("yj")%></td>
				<% 'End If %>
	<% End If %>
	<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<td><%=rs("jsj")%></td>
	<% End If %>
		<td><%=rs("dcf")%></td>
		<td><%=rs("tx")%></td>
		<td><%=rs("hx")%></td>
	<% If yc="yj" Or yc="" Then %>
		<td><%=rs("jgf")%></td>
	<% End If %>
	<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<td><%=rs("yfjgf")%></td>
	<% End If %>
	<td><%=rs("qtf")%></td>
			<% if yc="yue" then %>
			<td><%=rs("dz")%></td>
			<td><%
						
						if rs("jsj")="" or isnull(rs("jsj")) then jsj0=0 else jsj0=rs("jsj")
						if rs("yfjgf")="" or isnull(rs("yfjgf")) then yfjgf0=0 else yfjgf0=rs("yfjgf")
						glcbf=(jsj0+yfjgf0)*0.1
						response.write(glcbf)
														
			%></td>
			<td><%
						yue=rs("jsj")+rs("yfjgf")-rs("dz")-glcbf
						response.write(yue)
			%></td>
		<td><%if rs("baozhang") then response.write("√")%></td>
			<% End If %>
		<td><%=rs("bz")%></td>
	<% If yc="" Then %>
		<td><%if rs("js") then response.write("√")%></td>
		<td><%if rs("yf") then response.write("√")%></td>
	<% End If %>
	<% End If %>
  </tr>
<%
	sum_dcf=sum_dcf+rs("dcf")
	sum_jgf=sum_jgf+rs("jgf")
	sum_yfjgf=sum_yfjgf+rs("yfjgf")
	sum_yj=sum_yj+rs("yj")
	sum_jsj=sum_jsj+rs("jsj")
	sum_qtf=sum_qtf+rs("qtf")
	sum_chanzhi=sum_chanzhi+rs("chanzhi")
	sum_sjrlf=sum_sjrlf+rs("sjrlf")
	sum_thf=sum_thf+rs("thf")
	sum_dz=sum_dz+rs("dz")
	sum_glcbf=sum_glcbf+glcbf
	sum_yue=sum_yue+yue
	rs.movenext()
'wend
next
%>
</tbody>
<thead>
  <tr>
		<th>小计</th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
	<% if yc<>"yue" then %>
		<th></th>
		<% End If %>
		<th></th>
		<th></th>
		<th></th>
	<% if yc<>"yue" then %>
		<th></th>
		<% End If %>
		<% If yc="chanzhi" Then %>
		<th><%=sum_chanzhi%></th>
		<th><%=sum_sjrlf%></th>
		<th><%=sum_thf%></th>
		<% else %>
		<% If yc="yj" Or yc="" Then %>
				<% 'If Session("MM_Post")=0 Then %>
		<th><%=sum_yj%></th>
				<% 'End If %>
		<% End If %>
		<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<th><%=sum_jsj%></th>
		<% End If %>
		<th><%=sum_dcf%></th>
		<th></th>
		<th></th>
		<% If yc="yj" Or yc="" Then %>
		<th><%=sum_jgf%></th>
		<% End If %>
		<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<th><%=sum_yfjgf%></th>
		<% End If %>
		<th><%=sum_qtf%></th>
			<% if yc="yue" then %>
		<th><%=sum_dz%></th>
		<th><%=sum_glcbf%></th>
		<th><%=sum_yue%></th>
		<th></th>
			<% end if %>
		
		<th></th>
		<% If yc="" Then %>
		<th></th>
		<th></th>
		<% End If %>
		<% End If %>
  </tr>
		<%If page=pagecount Then %>
  <tr>
		<th>总计</th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
		<th></th>
	<% if yc<>"yue" then %>
		<th></th>
			<% End If %>
		<th></th>
		<th></th>
		<th></th>
	<% if yc<>"yue" then %>
		<th></th>
			<% End If %>
		<% If yc="chanzhi" Then %>
		<th><%=s_chanzhi%></th>
		<th><%=s_sjrlf%></th>
		<th><%=s_thf%></th>
		<% else %>
			<% If yc="yj" Or yc="" Then %>
				<% 'If Session("MM_Post")=0 Then %>
		<th><%=s_yj%></th>
				<% 'End If %>
			<% End If %>
			<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<th><%=s_jsj%></th>
			<% End If %>
		<th><%=s_dcf%></th>
		<th></th>
		<th></th>
			<% If yc="yj" Or yc="" Then %>
		<th><%=s_jgf%></th>
			<% End If %>
			<% If yc="jsj" Or yc="" or yc="yue" Then %>
		<th><%=s_yfjgf%></th>
			<% End If %>
		<th><%=s_qtf%></th>
			<% if yc="yue" then %>
		<th><%=s_dz%></th>
		<th><%=s_glcbf%></th>
		<th><%=s_yue%></th>
		<th></th>
			<% end if %>
		<th></th>
			<% If yc="" Then %>
		<th></th>
		<th></th>
			<% End If %>
		<% End If %>
  </tr>
  <% End If %>
</thead>
</table>
<div>
	<span id="pagebar">
		<%	If page>1 Then	%>
			[<a href="#" id="1">首页</a>]
			[<a href="#" id="<%=page-1%>">上一页</a>]
		<%
				End If
				If Not (page>=pagecount Or pagecount=0) Then
		%>
			[<a href="#" id="<%=page+1%>">下一页</a>]
			[<a href="#" id="<%=pagecount%>">尾页</a>]
		<%	End If %>
			第 <%=page%> 页 / 共 <%=pagecount%> 页
			转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
			<input id="page_go" type="button" value="Go" />
	</span>
  <span>
		<% if yc="" then %>
		<input id="ys_yes" type="button" value="&nbsp;收&nbsp;" />
		<input id="ys_no" type="button" value="&nbsp;!收&nbsp;" />
		<input id="yf_yes" type="button" value="&nbsp;付&nbsp;" />
		<input id="yf_no" type="button" value="&nbsp;!付&nbsp;" />
		<%	End If %>
		<% if yc="yue" then %>
		<input id="bz_yes" type="button" value="&nbsp;报&nbsp;" />
		<input id="bz_no" type="button" value="&nbsp;!报&nbsp;" />
		<%	End If %>
	</span>
</div>
<%
rs.close
Set rs=nothing
conn.close
Set conn=nothing
%>
